home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
apidev
/
dax1.exe
/
DAP
/
DAPE
/
DAPIO.C
< prev
next >
Wrap
Text File
|
1992-07-15
|
4KB
|
116 lines
// ╔════════════════════════════════════════════════════════════════════╗
// ║ ║
// ║ module: dapio.c ║
// ║ abstract: This module contains the screen IO logic. ║
// ║ ║
// ║ environment: NetWare 3.x v3.11 ║
// ║ Network C for NLMs SDK ║
// ║ CLib v3.11 ║
// ║ ║
// ║ This software is provided as is and carries no warranty ║
// ║ whatsoever. Novell disclaims and excludes any and all implied ║
// ║ warranties of merchantability, title and fitness for a particular ║
// ║ purpose. Novell does not warrant that the software will satisfy ║
// ║ your requirements or that the software is without defect or error ║
// ║ or that operation of the software will be uninterrupted. You are ║
// ║ using the software at your risk. The software is not a product ║
// ║ of Novell, Inc. or any of subsidiaries. ║
// ║ ║
// ╟────────────────────────────────────────────────────────────────────╢
// ║ maintenance history: ║
// ║ level date pi description ║
// ╟────────────────────────────────────────────────────────────────────╢
// ║ 001 02/24/92 kl initial release. ║
// ╚════════════════════════════════════════════════════════════════════╝
#include <stdio.h>
#include <stdarg.h>
#include <conio.h>
#include <process.h>
#include <nwsemaph.h>
#include "dap/dapsys.h"
#define MAXLINE 255
STATIC LONG ioSemaphore;
T_RC DAPInitializeIOLogic()
{
//
// We need a local semaphore to block the print thread
//
if( (ioSemaphore = OpenLocalSemaphore(1)) == -1){
ioSemaphore = 0; // so we don't accidentally close it
return DAP_RESOURCE_ERROR;
}
gotoxy(0,24); // put cursor at bottom of screen
SetCtrlCharCheckMode(FALSE);
DIAG4("IO Logic has been initialized");
return DAP_SUCCESS;
}
void DAPDeInitializeIOLogic()
{
//
// Most of the time, this API will be called during atexit()
// processing.
//
if( ioSemaphore ){
CloseLocalSemaphore(ioSemaphore);
ioSemaphore = 0; // so it isn't closed again...
}
DIAG4("IO Logic has been DE-initialized");
}
//
// Notice how both of the printing APIs make sure that a valid
// semaphore is available before calling the OS routine. This is
// necessary since we may need to use these APIs while the IO
// engine has not been initialized.
//
int DAPatprintf(WORD row, WORD col, char *fmt, ... )
{
int rc;
char _buf[MAXLINE]; // printf buffer
WORD oldrow,oldcol;
va_list argp; // pointer to arguments
if( ioSemaphore ) WaitOnLocalSemaphore(ioSemaphore);
va_start(argp, fmt);
vsprintf(_buf, fmt, argp);
va_end(argp);
GetPositionOfOutputCursor( &oldrow, &oldcol );
gotoxy(col,row);
rc = printf(_buf);
gotoxy(oldcol,oldrow);
if( ioSemaphore ) SignalLocalSemaphore(ioSemaphore);
return rc;
}
STATIC LONG cLine = 3; // current line number in bottom window
STATIC void DAPMoveCursorInStatusWindowDown( WORD lines )
{
if( (cLine += lines) >= 23 ){
for( ; cLine > 22; --cLine )
ScrollScreenRegionUp(4, 19);
}
}
int DAPprintf(char *fmt, ... )
{
int rc;
char _buf[MAXLINE]; // printf buffer
va_list argp; // pointer to arguments
va_start(argp, fmt);
vsprintf(_buf, fmt, argp);
va_end(argp);
DAPMoveCursorInStatusWindowDown(1);
rc = DAPatprintf(cLine,0,_buf);
return rc;
}